﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace FMS.Core.Database
{
    public interface IRepository<TEntity>
    {
        void Add(TEntity entity);
        void Update(TEntity entity);
        void Delete(TEntity entity);
        void Delete(int id);
        void Copy(TEntity source, TEntity target);
        void Flush();

        TEntity Get(int id);
        TEntity Get(Expression<Func<TEntity, bool>> predicate);

        IQueryable<TEntity> Table { get; }

        int Count(Expression<Func<TEntity, bool>> predicate);
        IEnumerable<TEntity> Fetch(Expression<Func<TEntity, bool>> predicate);
        IEnumerable<TEntity> Fetch(Expression<Func<TEntity, bool>> predicate, int skip, int count);
    }
}
